package utils;

import javax.servlet.http.Cookie;

public class CookieUtils {

    /**
     * 查找指定名称的cookie
     * @param cookies 查找范围
     * @param cookieName 查找cookie名称
     * @return 找到那个名称的cookie
     */
    public static Cookie findCookie(Cookie[] cookies,String cookieName){
        Cookie targetCookie = null;
        if (cookies != null){
            for (Cookie cookie : cookies) {
                if (cookie.getName().equals(cookieName)){
                    targetCookie = cookie;
                    break;
                }
            }
        }

        return targetCookie;
    }
}
